#include "cdcsync.h"
bool checkWindow(char* window,const unsigned long window_size, const unsigned int d, const unsigned int r){
	const size_t offset_stpe = sizeof(unsigned long) - sizeof(unsigned int);
	const size_t offset_stpe_bit = offset_stpe * 8;

	unsigned long offset = 0;
	unsigned long t = (unsigned long)(&window) >> (offset_stpe * 8);
	for(offset = 0; offset <= window_size - sizeof(unsigned long); offset += offset_stpe){
		t = ((unsigned long)(&window) << offset_stpe_bit >> offset_stpe_bit + (t << offset_stpe_bit)) % d;
		window += offset_stpe;
	}
	size_t l;
	
	if(l = window_size - offset){
		size_t off = sizeof(unsigned long) - l;
		size_t off_bit = off * 8;
		window -= off;
		t = ((unsigned long)(&window) << off_bit >> off_bit + (t << off_bit)) % d;
	};

	return r == t;
}